/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ClassUI.java
 *
 * Created on 11 2, 11, 12:10:30 AM
 */
package introsemp;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

/**
 *
 * @author Marit
 */
public class ClassUI extends javax.swing.JPanel {

    /** Creates new form ClassUI */
    JFrame frame;
    
    public ClassUI() {
        initComponents();
        JLabel bg = new JLabel(new ImageIcon("Images\\handled classes.png"));
        bg.setSize(930, 686);
        add(bg);
        bg.setVisible(true);
    }
    
    public void remove() {
        frame.remove(this);
    }
    public void setFrame(JFrame frame) {
        this.frame = frame;
        frame.add(this);
        frame.validate();
        frame.setSize(930, 686);
    }
    
        public void addHandle(){
            String[] year = {"1", "2", "3", "4"};
            String[] section = {"Faith", "Hope", "Charity", "Prudence"};
            String[] subjects = {"Filipino", "English", "Mathematics", "Araling Panlipunan", "Economics"};
            
            final JDialog dbox = new JDialog();
            JComboBox yearList = new JComboBox(year);
            JComboBox sectionList = new JComboBox(section);
            JComboBox subjectList = new JComboBox(subjects);
            JButton ok = new JButton("OK");
            JButton cancel = new JButton("Cancel");
            dbox.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            dbox.setSize(417,310);
            dbox.setLayout(null);

            ok.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        JOptionPane.showMessageDialog(dbox,"<Year><Section>-<Subject> has been \n"+"succesfully added.\n"+" ");
                        dbox.dispose();
                    }
            });
            cancel.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        dbox.dispose();
                    }
            });

            yearList.setSize(60, 26);
            sectionList.setSize(135, 26);
            subjectList.setSize(200, 26);
            
            yearList.setLocation(120, 105);
            sectionList.setLocation(185, 105);
            subjectList.setLocation(120, 150);
            
            yearList.setVisible(true);
            subjectList.setVisible(true);


            ok.setSize(80, 25);
            cancel.setSize(80, 25);
            
            ok.setLocation(120, 200);
            cancel.setLocation(210, 200);
            
            ok.setVisible(true);
            cancel.setVisible(true);

            dbox.add(ok);
            dbox.add(cancel);
            dbox.add(yearList);
            dbox.add(sectionList);
            dbox.add(subjectList);
            
            JLabel bg = new JLabel(new ImageIcon("Images\\add class handle.png"));
            bg.setSize(400, 270);
            bg.setVisible(true);
            dbox.add(bg);
            
            dbox.setVisible(true);
    }
    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        handleTable = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jButton1 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        jButton5 = new javax.swing.JButton();
        Button2 = new javax.swing.JButton();
        Button4 = new javax.swing.JButton();
        Button1 = new javax.swing.JButton();
        logoutButton = new javax.swing.JButton();

        handleTable.setFont(new java.awt.Font("Verdana", 0, 13)); // NOI18N
        handleTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "No.", "Name"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(handleTable);

        jLabel1.setFont(new java.awt.Font("Verdana", 0, 13)); // NOI18N
        jLabel1.setText("Handles:");

        jList1.setFont(new java.awt.Font("Verdana", 0, 13)); // NOI18N
        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "1 - Wisdom (English)", "2 - Piety (English)", "3 - Justice (Science)", "4 - Perseverance (Filipino)" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane2.setViewportView(jList1);

        jButton1.setFont(new java.awt.Font("Verdana", 0, 13)); // NOI18N
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/introsemp/add.png"))); // NOI18N
        jButton1.setText("Add a Section");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton3.setFont(new java.awt.Font("Verdana", 0, 13));
        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/introsemp/Delete.png"))); // NOI18N
        jButton3.setText("Delete Section");

        jTextField1.setFont(new java.awt.Font("Verdana", 0, 13)); // NOI18N

        jButton5.setFont(new java.awt.Font("Verdana", 0, 13)); // NOI18N
        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/introsemp/search.png"))); // NOI18N
        jButton5.setText("Search");

        Button2.setContentAreaFilled(false);
        Button2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        Button2.setFocusPainted(false);
        Button2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button2ActionPerformed(evt);
            }
        });

        Button4.setContentAreaFilled(false);
        Button4.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        Button4.setFocusPainted(false);
        Button4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button4ActionPerformed(evt);
            }
        });

        Button1.setContentAreaFilled(false);
        Button1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        Button1.setFocusPainted(false);
        Button1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button1ActionPerformed(evt);
            }
        });

        logoutButton.setFont(new java.awt.Font("Verdana", 0, 13)); // NOI18N
        logoutButton.setText("Log out");
        logoutButton.setContentAreaFilled(false);
        logoutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Button4, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE)
                    .addComponent(Button2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE)
                    .addComponent(Button1, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE))
                .addGap(46, 46, 46)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jTextField1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton5))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 393, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(29, 29, 29)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(33, 33, 33))
            .addGroup(layout.createSequentialGroup()
                .addGap(64, 64, 64)
                .addComponent(logoutButton)
                .addContainerGap(744, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(168, 168, 168)
                        .addComponent(Button1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Button2, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(53, 53, 53)
                        .addComponent(Button4, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap(152, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addGap(13, 13, 13)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(13, 13, 13)
                                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 467, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE)
                    .addComponent(jButton5))
                .addGap(13, 13, 13)
                .addComponent(logoutButton, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
    }// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    addHandle();// TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed

private void Button2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button2ActionPerformed
    remove();
    GradeBreakdownUI a = new GradeBreakdownUI(0);
    a.setFrame(frame);
    // TODO add your handling code here:
}//GEN-LAST:event_Button2ActionPerformed

private void Button4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button4ActionPerformed
    remove();
    ComponentsUI c = new ComponentsUI(0);
    c.setFrame(frame);// TODO add your handling code here:
}//GEN-LAST:event_Button4ActionPerformed

private void Button1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button1ActionPerformed
    remove();
    GradesUI g = new GradesUI(0);
    g.setFrame(frame);// TODO add your handling code here:
}//GEN-LAST:event_Button1ActionPerformed

private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutButtonActionPerformed
    JDialog dbox = new JDialog();
    dbox.setSize(400,250);
    int response = JOptionPane.showConfirmDialog(
                    dbox, "Are you sure you want to log out?", " ", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
            if (response == JOptionPane.YES_OPTION ) {
                dbox.dispose();
                System.exit(0);
            } else if (response == JOptionPane.NO_OPTION ) {
                dbox.dispose();
            }    // TODO add your handling code here:
}//GEN-LAST:event_logoutButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Button1;
    private javax.swing.JButton Button2;
    private javax.swing.JButton Button4;
    private javax.swing.JTable handleTable;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton5;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JList jList1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JButton logoutButton;
    // End of variables declaration//GEN-END:variables
}
